export default function use$cookie(name: string) {
  const login = useCookie<LoginResp | undefined | null>(name);

  const hasLogin = computed(() => login && login.value);
  const hasAuth = computed(() => hasLogin && login.value?.token);
  const token = computed(() => (hasAuth ? login.value?.token : null));
  const user = computed(() => (hasAuth ? login.value?.user : null));
  const email = computed(() => user.value?.email || null);
  const userID = computed(() => user.value?.id || null);
  // const userRole = computed(()=>user.value?.role||null);
  // const userStatus = computed(()=>user.value?.status||null);

  return { auth: login, token, user, email, userID };
}
